import axios from 'axios'
import { Toast } from 'vant'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const service = axios.create({
  baseURL: 'http://127.0.0.1:3000'
})

// axios 请求拦截
service.interceptors.request.use(config => {
  NProgress.start()
  return config
}, err => {
  Promise.reject(err)
})

// 拦截响应
service.interceptors.response.use(response => {
  NProgress.done()
  return response
}, err => {
  Toast('网络请求失败')
  Promise.reject(err)
})
export default service
